

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require("clean-webpack-plugin");

module.exports = {
  devServer: {
    contentBase: path.join(__dirname, "public"),
    compress: false,
    port: 9000,
    open: false,
    hot: true
  },
  entry: {
    app: './src/index.js'
  },

  devtool: 'inline-source-map',
  plugins: [
    new HtmlWebpackPlugin({
      title: 'Development',
      //注意传的参数是一个对象
      template: './public/index.html'   //传一个模板，就是根目录下的index.html
    }),
    new CleanWebpackPlugin()
  ],
  output: {
    filename: 'js/[name].js', //打包后的文件名
    path: path.resolve(__dirname, 'dist')
  }
};